package com.xiaoxie.mapper;

import com.xiaoxie.entity.Lexicon;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface LexiconDao {

    //获取账号词本
    @Select("select * from lexicon where account = #{account}")
    List<Lexicon> getAll(String currentAccount);

    //获取所有可访问词本
    @Select("select id,account,name,word_Number,`show` from lexicon where account = #{account} or `show`=1 ")
    List<Lexicon> showAll(String currentAccount);

    //删除词本
    @Delete("delete from lexicon where account = #{account} and id = #{id}")
    void deleteLexicon(String account, Integer id);
    @Update("update lexicon set word_Number=word_Number+1 where account=#{account} and id = #{id}")
    void inset(String account, Integer id);

    @Update("update lexicon set word_Number=word_Number-1 where account=#{account} and id = #{id}")
    void delete(String account, Integer id);
}
